package flc.ast.adapter;

import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyAlbumBean;
import flc.ast.bean.MyPicLibraryBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class PicAlbumAdapter extends StkProviderMultiAdapter<MyPicLibraryBean> {

    public PicAlbumAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(80));
        addItemProvider(new PicAlbumProvider());
    }


    private class PicAlbumProvider extends BaseItemProvider<MyPicLibraryBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_video_album;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyPicLibraryBean bean) {
            if (bean.getList().size() == 0 || bean.getList() == null) {
                baseViewHolder.setImageResource(R.id.ivVideoAlbumItemImg, R.drawable.atianjiatukwzt);
            } else {
                Glide.with(baseViewHolder.itemView).load(bean.getList().get(0)).into((ImageView) baseViewHolder.getView(R.id.ivVideoAlbumItemImg));
            }
            baseViewHolder.setText(R.id.tvVideoAlbumItemName, bean.getName());
            baseViewHolder.setText(R.id.tvVideoAlbumItemNum, getContext().getString(R.string.picture_num, bean.getList().size()));

        }
    }
}
